/*

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; version 2
 of the License.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/

#import "iPhoneOSBuild.h"

#if USE_CORESURFACE

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#import "CoreSurface.h"
#import "DoomEvent.h"

#define true 1
#define false 0
#define __BYTEBOOL__

#include <pthread.h>
#include "doom/doomdef.h"
#include "doom/d_event.h"

CoreSurfaceBufferRef screenSurface;
pthread_cond_t screenUpdateLock;
pthread_mutex_t screenUpdateMutex;

@interface UIDoomScreenView : UIView <UITextInputTraits> 
{
	int currOrient;
	int currRot;
	id screenLayer;
	BOOL initGraphics;
	
    NSMutableArray* eventQueue;
    CGPoint lastMousePos;
    int lastKey;
	
	UIAccelerationValue accelerationX;
    UIAccelerationValue accelerationY;
    UIAccelerationValue accelerationZ;
	
	int mouseX;
	int mouseY;
}

- (id)initWithFrame:(CGRect)frame;
- (void)drawRect:(CGRect)frame;
- (void)updateScreen;
- (void)dealloc;

@end

@interface UIDoomScreenView (Input) <UIAccelerometerDelegate>
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration;
- (int)getNextEvent:(event_t*)event;
@end

#endif